package com.aabte.spring.aop;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.*;

/**
 * @author Daniel
 */
@Aspect
public class LogAspects {

    @Pointcut(value = "execution(public * com.aabte.spring.aop.MathCaculator.*(..))")
    public void pointCut() {
    }

    @Before("pointCut()")
    public void logStart(JoinPoint joinPoint) {
        System.out.println("Invoke @Before advice method... joinPoint = " + joinPoint);
    }

    @After("pointCut()")
    public void logEnd(JoinPoint joinPoint) {
        System.out.println("Invoke @After advice method... joinPoint = " + joinPoint);
    }

    @AfterReturning(value = "pointCut()", returning = "result")
    public void logReturn(JoinPoint joinPoint, Object result) {
        System.out.println("Invoke @AfterReturning advice method... joinPoint = " + joinPoint + " result = " + result);
    }

    @AfterThrowing(value = "pointCut()", throwing = "ex")
    public void logException(JoinPoint joinPoint, Exception ex) {
        System.out.println("Invoke @AfterThrowing advice method... joinPoint = " + joinPoint + " ex = " + ex);
    }

}
